package darknet.core.impl.net;

import darknet.core.spec.net.MessageHeader;
import darknet.core.spec.net.Protocol;

/**
 * Implementation of a message header.
 * 
 * @author Yoyo
 */
@SuppressWarnings("serial")
public class MessageHeaderImpl implements MessageHeader {

    /** The protocol */
    private Protocol protocol;
    
    /**
     * Initialise a new Message Header.
     * 
     * @param protocol The protocol.
     */
    public MessageHeaderImpl(Protocol protocol) {

	if (protocol == null) {
	    throw new IllegalArgumentException("protocol is null");
	}
	this.protocol = protocol;
    }

    @Override
    public Protocol getProtocol() {
	return protocol;
    }

    @Override
    public String toString() {

        StringBuilder builder = new StringBuilder("MessageHeaderImpl[");
        builder.append("protocol=");
        builder.append(protocol.toString());
        builder.append("]");

        return builder.toString();
    }
}
